#include<iostream>
using namespace std;

#define SIZE 64
#define BIG 99999
#define STEP 8
#define BOARDSIZE 8
int walkx[]={-2,-2,2,2,-1,-1,1,1};
int walky[]={-1,1,-1,1,-2,2,-2,2};

int hashP(int x,int y){
	return (y<<3)+x;
}
bool inBoard(int x,int y){
	if(x>=0&&x<BOARDSIZE&&y>=0&&y<BOARDSIZE){
		return true;
	}else{
		return false;
	}
}
int main(){
	/** init part **/

	int arr[SIZE][SIZE];
	for(int i=0;i<SIZE;i++){
		for(int j=0;j<SIZE;j++){
			if(i==j) arr[i][j] = 0;
			else{
				arr[i][j] = BIG;
			}
		}
	}
	for(int i=0;i<BOARDSIZE;i++){
		for(int j=0;j<BOARDSIZE;j++){
			for(int s=0;s<STEP;s++){
				int newx = i + walkx[s];
				int newy = j + walky[s];
				if(inBoard(newx,newy)){
					arr[hashP(newx,newy)][hashP(i,j)] = 1;
				}
			}
		}
	}
	/** search **/
	
	int depth = 0;
	for(depth =0;depth<6;depth++){
		for(int i=0;i<SIZE;i++){
			for(int j=0;j<SIZE;j++){
				for(int temp=0;temp<SIZE;temp++){
					if(arr[i][temp]+arr[temp][j]<arr[i][j]){
						arr[i][j] = arr[i][temp]+arr[temp][j];
						arr[j][i] = arr[i][j];
					}
				}
			}
		}
	}
	
	/**  input part **/
	char line[3];
	int x1,x2, y1,y2;
	int n = 0;
	char temp1[2];
	char temp2[2];
	while(cin>>line){
		if(n%2 ==0){
			temp1[0] = line[0];
			temp1[1] = line[1];
			x1 = (int)(line[0])-(int)'a';
			y1 = (int)(line[1])-(int)'1';
			n++;
			continue;
		}else{
			temp2[0] = line[0];
			temp2[1] = line[1];
			x2 = (int)(line[0])-(int)'a';
			y2 = (int)(line[1])-(int)'1';
			cout<<"To get from "<<temp1[0]<<temp1[1]<<" to "<<temp2[0]<<temp2[1]<<" takes "<<arr[hashP(x1,y1)][hashP(x2,y2)]<<" knight moves."<<endl;
			n++;
		}
	}
	return 0;
}